package org.springcloud.wisdom.amusement.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Update;
import org.springcloud.wisdom.amusement.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentDao2 extends BaseMapper<Student> {
    @Select("select  * from student")
    public List<Student> selectStudent();

    @Select("select  * from student")
    IPage<Student> selectStudentPage(Page<?> page);
    @Select("select  * from student where sid=#{sid}")
    public Student selectAStudent(String sid);

    @Update("update student set talent=#{talent} where sid=#{sid}")
    public int AddTalent(String sid,String talent);

    @Update("<script>" +
            "  update student" +
            "        <set>" +
            "            <if test=\"null!= sid\">" +
            "                sid =#{sid}," +
            "            </if>" +
            "            <if test=\"null!= sname\">" +
            "                sname =#{sname}," +
            "            </if>" +
            "            <if test=\"null!= gender\">" +
            "                gender =#{gender}," +
            "            </if>" +
            "            <if test=\"null!= phone\">" +
            "                phone =#{phone}," +
            "            </if>" +
            "            <if test=\"null!= address\">" +
            "                address =#{address}," +
            "            </if>" +
            "            <if test=\"null!= talent\">" +
            "                talent =#{talent}," +
            "            </if>" +
            "        </set>" +
            "        where sid =#{sid}" +
            "</script>")
    public int update(Student student);
}
